function(Format target directory)
  find_program(CLANG-FORMAT_PATH clang-format REQUIRED)

  set(EXPRESSION h hpp hh c cc cxx cpp)

  list(TRANSFORM EXPRESSION PREPEND "${directory}/*.") 

  file(GLOB_RECURSE SOURCE_FILES FOLLOW_SYMLINKS LIST_DIRECTORIES false ${EXPRESSION}) 
 
  add_custom_command(TARGET ${target} PRE_BUILD COMMAND ${CLANG-FORMAT_PATH} --verbose -i --style=file ${SOURCE_FILES} )

endfunction()
